﻿using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;

namespace Level
{
    [CreateAssetMenu(fileName = "DifficultySetting", menuName = "Data/Difficulty Setting", order = 0)]
    public class DifficultySetting : ScriptableObject
    {
        public int EnemyCountBase => enemyCountBase;
        public int EnemyCountAdditionPerRound => enemyCountAdditionPerRound;
        
        [SerializeField] private int enemyCountBase = 5;
        [SerializeField] private int enemyCountAdditionPerRound = 5;
        
        [SerializeField] private Transform[] newEnemyTypeAtRound;
        [SerializeField] private int[] newWeaponTypeAtRound;
        
        [SerializeField] private int[] enemyCountPerBurstAtRound;
        [SerializeField] private float[] enemySpawnIntervalAtRound;


        [CanBeNull]
        public Transform GetNewEnemyTypeAtRound(int round)
        {
            return round >= newEnemyTypeAtRound.Length ? null : newEnemyTypeAtRound[round];
        }
        
        public int GetNewWeaponTypeAtRound(int round)
        {
            return round >= newWeaponTypeAtRound.Length ? 0 : newWeaponTypeAtRound[round];
        }

        public int GetEnemyCountPerBurstAtRound(int round)
        {
            if (round >= enemyCountPerBurstAtRound.Length)
            {
                return enemyCountPerBurstAtRound[enemyCountPerBurstAtRound.Length - 1];
            }
            
            return enemyCountPerBurstAtRound[round];
        }
        
        public float GetEnemySpawnIntervalAtRound(int round)
        {
            if (round >= enemySpawnIntervalAtRound.Length)
            {
                return enemySpawnIntervalAtRound[enemySpawnIntervalAtRound.Length - 1];
            }
            
            return enemySpawnIntervalAtRound[round];
        }
    }
}